<template>
  <span :class="[`icon-${props.name}`]" :style="styles" class="iconfont"></span>
</template>

<script lang="ts">
/**
 * 字体图标
 * @param {string} name 图标名称
 * @param {string} color 图标颜色
 * @param {number|string} size 图标大小
 * <font-icon color="" name=""></font-icon>
 * */
import { computed } from 'vue';

export default {
  name: 'FontIcon',
  props: {
    name: {
      type: String,
      default: ''
    },
    color: {
      type: String,
      default: ''
    },
    size: {
      type: [Number, String],
      default: 24
    }
  },
  setup(props) {
    const styles = computed(() => {
      const { size } = props;
      return {
        fontSize: !isNaN(size) ? String(size) + 'px' : size,
        color: props.color
      };
    });

    return {
      props,
      styles
    };
  }
};
</script>

<style></style>
